import java.util.Scanner;

public class Test04 {
    static final int MOD = 1000000007;
    private static long[] dp;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        if(n < 2){
            System.out.println(0);
            return;
        }
        long ret = countGoodString(n);
        System.out.println(ret);
    }

    private static long countGoodString(int n){
        if(n ==1) return 0;
        if(n == 2) return 3;
        if(n ==3) return 18;
        return (6 * (n+1)) % MOD;
    }
}
